package srjava.messages;

import java.io.IOException;
import java.io.StringReader;
import java.util.Iterator;
import java.util.LinkedList;

public class NumberOfTasksRet extends Message {
	LinkedList<ServerFullInfo> serverList;
	
	public NumberOfTasksRet() {
		this.msgType = MessageType.NUMBER_OF_TASKS_RET;
		this.serverList = new LinkedList<ServerFullInfo>();
	}

	@Override
	public String serialize() {
		String pom = super.serialize() + serverList.size() + " ";
		Iterator<ServerFullInfo> it = serverList.iterator();
		while (it.hasNext()) {
			pom += it.next().serialize();
		}
		return pom;
	}

	public LinkedList<ServerFullInfo> getServerList() {
		return serverList;
	}

	public void setServerList(LinkedList<ServerFullInfo> serverList) {
		this.serverList = serverList;
	}

	@Override
	public void deSerialize(StringReader s) throws IOException {
		int size = IntString.parseInt(s);
		for(int i=0; i<size; i++)
		{
			ServerFullInfo pom = new ServerFullInfo();
			pom.deSerialize(s);
			serverList.add(pom);
		}
	}
	
	
}
